package com.time.workshop.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.time.workshop.R;

/**
 * 显示老板是美男子弹出框
 * 
 * @author wangfeng
 *
 */
public class BuyTimeDialog extends AlertDialog implements OnClickListener
{

	private Context context;
	private OnClickOKListener onClickOK;

	public BuyTimeDialog(Context context)
	{
		super(context);
		this.context = context;
	}

	public void onCreate()
	{
		show();
		LayoutInflater factory = LayoutInflater.from(context);
		View view = factory.inflate(R.layout.submit_buytime_dialog, null);
		getWindow().setContentView(view);
		android.view.WindowManager.LayoutParams lp = getWindow().getAttributes();
		lp.width = android.view.WindowManager.LayoutParams.MATCH_PARENT;
		lp.height = android.view.WindowManager.LayoutParams.MATCH_PARENT;
		getWindow().setAttributes(lp);
		TextView mCancleTextBut = (TextView) view.findViewById(R.id.dialog_cancle_but_text);
		TextView mSureTextBut = (TextView) view.findViewById(R.id.dialog_sure_but_text);
		RelativeLayout all_window = (RelativeLayout) view.findViewById(R.id.all_window);
		RelativeLayout dialog_detail_relat = (RelativeLayout) view.findViewById(R.id.dialog_detail_relat);

		all_window.setOnClickListener(this);
		dialog_detail_relat.setOnClickListener(this);
		mCancleTextBut.setOnClickListener(this);
		mSureTextBut.setOnClickListener(this);

	}

	public void setOnClickOK(OnClickOKListener listener)
	{
		onClickOK = listener;
	}

	@Override
	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.dialog_cancle_but_text:
			dismiss();
			break;
		case R.id.all_window:
			dismiss();
			break;
		case R.id.dialog_sure_but_text:
			dismiss();
			onClickOK.setOnClickOK();
			break;
		case R.id.dialog_detail_relat:
			break;

		default:
			break;
		}
	}

}
